/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package modelo;

import java.io.Serializable;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Andre
 */
@Entity
@Table(name = "horario")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Horario.findAll", query = "SELECT h FROM Horario h"),
    @NamedQuery(name = "Horario.findByIdHorario", query = "SELECT h FROM Horario h WHERE h.idHorario = :idHorario"),
    @NamedQuery(name = "Horario.findByHoraInicio", query = "SELECT h FROM Horario h WHERE h.horaInicio = :horaInicio"),
    @NamedQuery(name = "Horario.findByHoraFim", query = "SELECT h FROM Horario h WHERE h.horaFim = :horaFim")})
public class Horario implements Serializable {
    
    private static final long serialVersionUID = 1L;
    
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "idHorario")
    private Integer idHorario;
    
    @Basic(optional = false)
    @NotNull
    @Size(min = 5, max = 5)
    @Column(name = "horaInicio")
    private String horaInicio;
    
    @Basic(optional = false)
    @NotNull
    @Size(min = 5, max = 5)
    @Column(name = "horaFim")
    private String horaFim;
    
    @Basic(optional = false)
    @NotNull
    @Column(name = "domingo")
    private boolean domingo;
    
    @Basic(optional = false)
    @NotNull
    @Column(name = "segunda")
    private boolean segunda;
    
    @Basic(optional = false)
    @NotNull
    @Column(name = "terca")
    private boolean terca;
    
    @Basic(optional = false)
    @NotNull
    @Column(name = "quarta")
    private boolean quarta;
    
    @Basic(optional = false)
    @NotNull
    @Column(name = "quinta")
    private boolean quinta;
    
    @Basic(optional = false)
    @NotNull
    @Column(name = "sexta")
    private boolean sexta;
    
    @Basic(optional = false)
    @NotNull
    @Column(name = "sabado")
    private boolean sabado;
    
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "horario")
    private List<Turma> turmaList;

    public Horario() {
    }

    public Horario(String horaInicio, String horaFim) {
        this.horaInicio = horaInicio;
        this.horaFim = horaFim;
    }

    public Integer getIdHorario() {
        return idHorario;
    }

    public String getHoraInicio() {
        return horaInicio;
    }

    public void setHoraInicio(String horaInicio) {
        this.horaInicio = horaInicio;
    }

    public String getHoraFim() {
        return horaFim;
    }

    public void setHoraFim(String horaFim) {
        this.horaFim = horaFim;
    }

    @XmlTransient
    public List<Turma> getTurmaList() {
        return turmaList;
    }

    public void setTurmaList(List<Turma> turmaList) {
        this.turmaList = turmaList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idHorario != null ? idHorario.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Horario)) {
            return false;
        }
        Horario other = (Horario) object;
        if ((this.idHorario == null && other.idHorario != null) || (this.idHorario != null && !this.idHorario.equals(other.idHorario))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        
        String retorno = horaInicio + " - " + horaFim + " :";
        
        if (isDomingo()){
            retorno += " Dom";
        }
        
        if (isSegunda()){
            retorno += " Seg";
        }
        
        if (isTerca()){
            retorno += " Ter";
        }
        
        if (isQuarta()){
            retorno += " Qua";
        }
        
        if (isQuinta()){
            retorno += " Qui";
        }
        
        if (isSexta()){
            retorno += " Sex";
        }
        
        if (isSabado()){
            retorno += " Sab";
        }
        
        return retorno;
    }

    public boolean isDomingo() {
        return domingo;
    }

    public void setDomingo(boolean domingo) {
        this.domingo = domingo;
    }

    public boolean isSegunda() {
        return segunda;
    }

    public void setSegunda(boolean segunda) {
        this.segunda = segunda;
    }

    public boolean isTerca() {
        return terca;
    }

    public void setTerca(boolean terca) {
        this.terca = terca;
    }

    
    public boolean isQuarta() {
        return quarta;
    }

    public void setQuarta(boolean quarta) {
        this.quarta = quarta;
    }

    public boolean isQuinta() {
        return quinta;
    }

    public void setQuinta(boolean quinta) {
        this.quinta = quinta;
    }

    public boolean isSexta() {
        return sexta;
    }

    public void setSexta(boolean sexta) {
        this.sexta = sexta;
    }

    public boolean isSabado() {
        return sabado;
    }

    public void setSabado(boolean sabado) {
        this.sabado = sabado;
    }
    
}
